﻿using B2B.Bussiness;
using B2B.ServiceReference1;
using B2B.Views;
using System;
using System.Windows.Controls;
using System.Windows.Navigation;

namespace B2B
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
        {
            if (e.Uri.OriginalString != "/Login")
            {
                menu1.Visibility = System.Windows.Visibility.Visible;
                Kullanici usr = Session.Instance.GetValue<Kullanici>("USER");
                if (usr != null)
                {
                    if (usr.Yonetici)
                    {
                        mnYonetim.Visibility = System.Windows.Visibility.Visible;
                    }
                }
                else
                {
                    ContentFrame.Navigate(new Uri("/Login", UriKind.Relative));
                }
            }
            else
            {
                menu1.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

        private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            e.Handled = true;
            //ErrorWindow.CreateNew(e.Exception);
        }

        private void HomeClick(object sender, EventArgs e)
        {
            ContentFrame.Navigate(new Uri("/Home", UriKind.Relative));
        }

        private void SiparisListesi(object sender, EventArgs e)
        {
            ContentFrame.Navigate(new Uri("/SiparisListesi", UriKind.Relative));
        }

        private void KullaniciTanitimClick(object sender, EventArgs e)
        {
            KullaniciTanitim frm = new KullaniciTanitim();
            frm.Show();
        }

        private void AgMenuItem_Click_1(object sender, EventArgs e)
        {
            GrupTanitim frm = new GrupTanitim();
            frm.Show();
        }
    }
}
